Add CLIProxyAPI cost attribution - #2457
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c82dab5a6d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs real behavior proof before merge. Reviewed August 21, 2026, 10:00 AM ET / 14:00 UTC. ClawSweeper reviewWhat this changesAdds CLIProxyAPI telemetry, upstream-provider attribution, caching, and spend-dashboard display for proxied Claude Code usage. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 9 items remain Keep open: two P2 correctness defects remain on the exact head, and the contributor has not supplied the required redacted live routed-run proof. Priority: P2 Review scores
Verification
How this fits togetherCodexBar combines Claude Code history with CLIProxyAPI logs and queue telemetry, resolves the upstream provider and model, then prices and displays that usage in the spend dashboard. flowchart LR
A[Claude Code history] --> C[Attribution resolver]
B[CLIProxyAPI logs and telemetry] --> C
C --> D[Provider and model pricing]
D --> E[Cost cache]
E --> F[Spend dashboard]
Decision needed
Why: The PR adds a large new provider-integration and configuration surface, so its long-term core ownership and scope need maintainer intent beyond mechanical fixes. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Persist removal-specific isolation provenance, recheck generation before memo returns, add focused crash/race regressions, and then provide a redacted live routed-run proof. Do we have a high-confidence way to reproduce the issue? Yes, at source level: advancing the durable generation during a memo return and starting removal with an existing disconnect marker exercise the two missing state checks; live provider proof remains absent. Is this the best way to solve the issue? No: the current approach needs durable removal-specific isolation provenance and memo-path generation validation before it is safe to merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f74117aeb7a9. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (119 earlier review cycles; latest 8 shown)
|
|
@codex review @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3bedb05f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Follow-up fixes are pushed in 0f4bda0 and the three current review threads have been addressed. @codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f4bda0d9a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
The current-head retention finding is fixed in e9b111e and its review thread is addressed. @codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9b111ef6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@clawsweeper re-review |
|
@codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Fixed both rollback findings from the canonical ClawSweeper checklist on head 1a66672:
Verification: focused CLIProxyAPIUsageCacheTests passed; make check passed; full make test passed all 828 selections across 69 groups with no retries or failures. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a66672e28
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the exact-head Codex P2 on c694017:
Verification: focused CLIProxyAPIUsageCacheTests passed; make check passed; full make test passed all 828 selections across 69 groups with no retries or failures. Both handled Codex threads have disposition replies and are resolved. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c694017bf6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Fixed the canonical ClawSweeper P2 cancellation finding in @codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Canonical finding fixed on exact head @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f971cad1a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b12543b40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68c572034e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: Add CLIProxyAPI cost attribution This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92ef1978dc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| let scanOptions = options | ||
| let proxyDaily = try await CostUsageScanExecutor.run { checkCancellation in | ||
| let range = CostUsageScanner.CostUsageDayRange(since: since, until: request.now) |
There was a problem hiding this comment.
Use the configured calendar for proxy scan ranges
When the dashboard's bucket timezone differs from the Mac's current timezone, this initializer silently uses .current even though since, the scanner options, and the final snapshot use options.calendar. Near a day boundary, proxy-attributed rows can therefore be assigned to or filtered by the wrong day, and the shared Claude cache is saved with the system timezone rather than the configured bucket timezone. Pass scanOptions.calendar into this range as the other scan paths do.
Useful? React with 👍 / 👎.
| case .missing: | ||
| KeychainCacheStore.clear(key: self.key) |
There was a problem hiding this comment.
Treat missing credentials as a successful rollback
Fresh evidence beyond the resolved removal path is that an initial save with no previous credential still restores .missing through KeychainCacheStore.clear, which returns false when the item is already absent (KeychainCacheStore.swift:254-255). If the Keychain store fails without creating an item, rollback consequently stops before restoring the disconnect marker and staged artifacts; recovery then treats credential rollback as unconfirmed, discards any staged telemetry, and leaves the integration explicitly disconnected. Accept both .removed and .missing from clearResult here.
Useful? React with 👍 / 👎.
Summary
Verification
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer make checkDEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer SWIFT_MODULECACHE_PATH=/tmp/codexbar-swift-module-cache CLANG_MODULE_CACHE_PATH=/tmp/codexbar-clang-module-cache make test(929 selections, 78 groups, all passed on the first attempt; 0 retries/timeouts)swift test --filter SpendDashboardProxyAttributionTestsDEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter CLIProxyAPIAttributionResolverTests(24 tests)DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter CostUsageFetcherCacheSnapshotTests(13 tests)swift test --filter CostUsageFetcherTests(18 tests)DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter CostUsageFetcherUnknownModelPricingTests(7 tests)swift test --filter SpendDashboardCodexProxySourceTests(2 tests)swift test --filter SpendDashboardForceStateMachineTests(14 tests)SpendDashboardTokenProvenanceTests,SpendDashboardControllerTests,CostUsageCacheTests, andCostUsageScannerClaudeFableTestsRemaining proof